set(LIB_NAME1 XclibProtocol)
set(LIB_NAME2 ModbusProtocol)
if (MSVC)
    add_definitions(-DLIBSERIALPORT_MSBUILD)
endif ()

find_package(micro-xclib CONFIG REQUIRED)
find_package(tinyxml2 CONFIG REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/errors)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ioadapter/pxd)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ioadapter/serial)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/codec)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/business/camera)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/business/sensor)

aux_source_directory(utils PROJ_UTILS)
aux_source_directory(common PROJ_COMMON)
aux_source_directory(errors PROJ_ERRORS)
aux_source_directory(ioadapter/pxd PROJ_IOADAPTER_PXD)
aux_source_directory(ioadapter/serial PROJ_IOADAPTER_SERIAL)
aux_source_directory(core PROJ_CORE)
aux_source_directory(codec PROJ_CODEC)
aux_source_directory(business/camera PROJ_BUSINESS_CAMERA)
aux_source_directory(business/sensor PROJ_BUSINESS_SENSOR)

add_library (${LIB_NAME1} STATIC
        ${PROJ_UTILS}
        ${PROJ_COMMON}
        ${PROJ_ERRORS}
        ${PROJ_IOADAPTER_PXD}
        ${PROJ_CORE}
        ${PROJ_CODEC}
        ${PROJ_BUSINESS_CAMERA}
)

target_link_libraries(${LIB_NAME1}
        PRIVATE
        tinyxml2::tinyxml2
        MICRO_XCLIB::MICRO_XCLIB
)

target_include_directories(${LIB_NAME1} PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}/common
        ${CMAKE_CURRENT_SOURCE_DIR}/ioadapter/pxd
        ${CMAKE_CURRENT_SOURCE_DIR}/core
        ${CMAKE_CURRENT_SOURCE_DIR}/codec
        ${CMAKE_CURRENT_SOURCE_DIR}/business/camera
        ${CMAKE_CURRENT_SOURCE_DIR}/wrapper
)

add_library (${LIB_NAME2} STATIC
        ${PROJ_UTILS}
        ${PROJ_COMMON}
        ${PROJ_ERRORS}
        ${PROJ_IOADAPTER_SERIAL}
        ${PROJ_CORE}
        ${PROJ_CODEC}
        ${PROJ_BUSINESS_SENSOR}
)

target_link_libraries(${LIB_NAME2}
        PRIVATE
        setupapi
        tinyxml2::tinyxml2
        libserialport
)

target_include_directories(${LIB_NAME2} PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}/common
        ${CMAKE_CURRENT_SOURCE_DIR}/ioadapter/serial
        ${CMAKE_CURRENT_SOURCE_DIR}/core
        ${CMAKE_CURRENT_SOURCE_DIR}/codec
        ${CMAKE_CURRENT_SOURCE_DIR}/business/sensor
        ${CMAKE_CURRENT_SOURCE_DIR}/wrapper
)